package com.qo.qsdk.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.qo.qsdk.QSDK;
import com.qo.qsdk.ui.base.PwdView;
import com.qo.qsdk.ui.base.TipView;

public class PwdActivity extends BaseActivity {

    private PwdView mPwdView;
    public static final String TIP_EXTRA = "TIP_EXTRA";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPwdView = new PwdView(this, mQSDKListener);
        mPwdView.show(this);
    }

    public static void start(Activity activity) {
        Intent intent = new Intent(activity, PwdActivity.class);
        activity.startActivity(intent);
    }

    QSDKListener mQSDKListener = new QSDKListener(){

        @Override
        public void onPwdAgain() {
            finish();
        }

        @Override
        public void onPwdClose() {
            finish();
        }

        @Override
        public void onPwdService() {
            QSDK.getInstance().showService(PwdActivity.this, null);
        }
    };


    @Override
    public void onBackPressed() {
        if (mQSDKListener != null) mQSDKListener.onPwdClose();
        super.onBackPressed();
    }

    @Override
    protected void onDestroy() {
        if (mPwdView != null) mPwdView.hide(this);
        super.onDestroy();
    }
}
